<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!--
            指令修饰符
            通过"."指明一些指令的后缀，不同后缀装了不同的处理操作 -> 简化代码
            1 按键修饰符
                @keyup.enter   -> 键盘回车监听
            2 v-model修饰符
                v-mode.trim    -> 去除首尾空格
                v-model.number -> 转数字
            3 事件修饰符
                @事件名.stop    -> 阻止冒泡
                @事件名.prevent -> 阻止默认行为 
        -->
        <h3>@keyup.enter -> 监听键盘回车事件</h3>
        <input @keyup.enter="fn"  v-model="username" type="text" />
        <br>
        <input @keyup="fn1"  v-model="anothername" type="text" />
    </div>

    <script src="../lib/vue.js"></script>

    <script>
        const app = new Vue({
            el: "#app",
            data() {
                return {
                    username: "",
                    anothername: ''
                }
            },
            methods: {
                fn() {
                    console.log('键盘回车时候出发', this.username)
                },
                fn1(e) {
                    //e事件信息
                    //console.log(e)
                    if(e.key === 'Enter') {
                        console.log('键盘回车时候出发', this.anothername)
                    }
                },
            }
        })
    </script>
</body>

</html>